package com.itbuka.vip.controller;

import com.itbuka.vip.domain.VipRechargeRecords;
import com.itbuka.vip.service.VipRechargeRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.itbuka.entity.Result;
import com.itbuka.entity.PageResult;
import com.github.pagehelper.Page;

import java.util.List;

/**
 * 会员充值记录
 */
@RestController
@RequestMapping("/VipRechargeRecords")
public class VipRechargeRecordsController {
    
    @Autowired
    private VipRechargeRecordsService vipRechargeRecordsService;

    /**
     * 查询全部
     */
    @GetMapping("/selectAll")
    public Result<List<VipRechargeRecords>> selectAll() {
        return Result.ok("查询成功", vipRechargeRecordsService.selectAll());
    }
    
    /**
     * 条件查询
     */
    @PostMapping("/selectList")
    public Result<List<VipRechargeRecords>> select(@RequestBody VipRechargeRecords vipRechargeRecords) {
        return Result.ok("条件查询成功", vipRechargeRecordsService.selectList(vipRechargeRecords));
    }

    /**
     * 新增
     */
    @PostMapping("/insert")
    public Result<?> insert(@RequestBody VipRechargeRecords vipRechargeRecords) {
        vipRechargeRecordsService.insert(vipRechargeRecords);
        return Result.ok("新增成功");
    }
    
    /**
     * 删除
     */
    @GetMapping("/delete")
    public Result<?> delete(@RequestParam String ids) {
        vipRechargeRecordsService.delete(ids);
        return Result.ok("删除成功");
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public Result<?> update(@RequestBody VipRechargeRecords vipRechargeRecords) {
        vipRechargeRecordsService.update(vipRechargeRecords);
        return Result.ok("修改成功");
    }

    /**
     * 分页搜索实现
     */
    @GetMapping(value = "/pageAll")
    public Result<?> pageAll(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
        Page<VipRechargeRecords> pageList = vipRechargeRecordsService.pageAll(page, size);
        PageResult<?> pageResult = new PageResult<>(pageList.getTotal(), pageList.getResult());
        return Result.ok("查询成功", pageResult);
    }

    /**
     * 分页条件搜索实现
     */
    @GetMapping(value = "/pageList")
    public Result<?> pageList(@RequestBody VipRechargeRecords vipRechargeRecords, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
        Page<VipRechargeRecords> pageList = vipRechargeRecordsService.pageList(vipRechargeRecords, page, size);
        PageResult<?> pageResult = new PageResult<>(pageList.getTotal(), pageList.getResult());
        return Result.ok("查询成功", pageResult);
    }
}




